﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DomainModel;

namespace SmartNote.Controllers
{
    public class HomeController : Controller
    {
        public HomeController()
        {
            Model = new SmartNoteDefaultModel();

            Tag tag1 = new Tag() { Name = "Tag1" };
            Tag tag2 = new Tag() { Name = "Tag2" };
            Tag tag21 = new Tag() { Name = "Tag21" };

            Model.addTag(tag1, 0);
            Model.addTag(tag2, 0);
            Model.addTag(tag21, tag2.Id);
        }

        public ActionResult Index()
        {
            return View();
        }    

        public JsonResult TreeTags()
        {
            TagNode root = new TagNode();
            root.build(Model);
            return Json(root, JsonRequestBehavior.AllowGet);
        }

        public ISmartNoteModel Model { get; set; }
    }
}
